package com.xuetang9.t9.hotel.mapper;

import com.xuetang9.t9.hotel.beans.EStaffinfo;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

public interface EStaffinfoMapper{
    @Select("select * from e_staffinfo")
    List<EStaffinfo> queryStaffList();

    @Insert("insert e_staffinfo(id, name, sex, phoneNum, `rank`, loginNum, loginPass, cardNum, brithDate) VALUES (#{id},#{name},#{sex},#{phone},#{rank},#{login},#{pass},#{cardNum},#{birthday})")
    int insertStaff(@Param("id")Integer id,@Param("name")String name,@Param("sex")String sex,@Param("phone")String phone,@Param("rank")String rank,@Param("login")String login,@Param("pass")String pass,@Param("cardNum")String cardNum,@Param("birthday") Date birthday);

    @Delete("delete from e_staffinfo where id=#{id}")
    int deleteStaff(@Param("id")int id);

    @Update("update e_staffinfo set name=#{name},sex=#{sex},phoneNum=#{phone},e_staffinfo.`rank`=#{rank},loginNum=#{login},loginPass=#{pass},cardNum=#{cardNum},brithDate=#{birthday} where id=#{id}")
    int updateStaff(@Param("id")Integer id,@Param("name")String name,@Param("sex")String sex,@Param("phone")String phone,@Param("rank")String rank,@Param("login")String login,@Param("pass")String pass,@Param("cardNum")String cardNum,@Param("birthday") Date birthday);

    @Select("select count(0) from e_staffinfo")
    int queryCount();

    @Select("select * from e_staffinfo where loginNum=#{user} and loginPass=#{password}")
    EStaffinfo queryOne(@Param("user")String name,@Param("password")String passWord);

    @Select("select * from e_staffinfo where loginNum=#{name}")
    EStaffinfo queryLogin(@Param("name")String name);

    @Update("update e_staffinfo set name=#{name} where id=#{id}")
    int updateName(@Param("name")String name,@Param("id")Integer id);

    @Update("update e_staffinfo set loginPass=#{Pass} where id=#{id}")
    int updatePass(@Param("Pass")String pass,@Param("id")Integer id);

    @Update("update e_staffinfo set phoneNum=#{phone} where id=#{id}")
    int updatePhone(@Param("phone")String phone,@Param("id")Integer id);

    @Select("select * from e_staffinfo where id = #{id}")
    EStaffinfo queryById(@Param("id")Integer id);
}